package com.activeMq.entity;

import javax.jms.*;

public class TextMessageLestener implements MessageListener {
    public void onMessage(Message message) {
        if(message instanceof TextMessage){
            TextMessage tm=(TextMessage)message;
            try {
                System.out.println("收到文本消息"+tm.getText());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
        if(message instanceof ObjectMessage){
            ObjectMessage tm=(ObjectMessage)message;
            try {
                System.out.println("收到对象消息"+tm.getObject());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}
